{extend name="$base" /}
{block name="resources"}
<style>
.nav-config-block{
	overflow:hidden;
	box-sizing:border-box;
	line-height:30px;
}
.nav-config-title{
	float:left;
	margin-right:10px;
	padding:6px 6px;
}
.nav-config-content{
	float:left;
	margin-top:6px;
}
.nav-config-content label .radio-common{
	margin-bottom: 4px;
}
.table-header{
	width:100%;
    border-top: 1px solid #e6e9f0;
    border-bottom: 1px solid #e6e9f0;
    background: #f5f7fa;
    font-weight: normal;
    font-size: 12px;
	text-align:left;
	box-sizing:border-box;
	padding:6px 6px;
}
.border-line{
	width:99.8%;
    border: 1px solid #e6e9f0;
	border-top:0;
	margin-bottom:10px;
}
.dis-block{
	display:block;
}
.dis-none{
	display:none;
}
.danger{color:red;}
</style>
{/block}
{block name="main"}
<div class="modal fade hide" id="modify_user" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

	<div class="modal-dialog" >
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h3 class="modal-title">回复</h3>
			</div>
			<div class="modal-body" style="min-height: 360px;">
				<div class="modal-infp-style">
					<table class="modal-tab">


						<tr>
							<td>回复内容</td>
							<td colspan='3'>
								<textarea rows="10" type="text" id="reply" class="input-common" style="width: 100%">
								</textarea>
							</td>
						</tr>


					</table>
				</div>
			</div>

			<div class="modal-footer">
				<input type="hidden" id="modify_id" />

				<button class="btn-common btn-big" onclick="modifyUser()" id="butSubmit"  >保存</button>
				<button class="btn-common-cancle btn-big" data-dismiss="modal">关闭</button>
			</div>
		</div>
	</div>

</div>
<table class="table-class">

	<thead>
		<tr align="center">
			<th align="left"></th>
			<th align="left">会员</th>
			<th align="left">反馈内容</th>
			<th align="left">反馈截图</th>
			<th align="left">回复</th>
			<th align="left">状态</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody></tbody>
</table>
{/block}
{block name="script"}
<script type="text/javascript">
	function modify_user(id){
		var id = parseInt(id);
		$("#modify_user").modal("show");
		$("#modify_id").val(id);
	}


function LoadingInfo(page_index) {
	var search_text = $("#search_text").val();
	$.ajax({
		type : "post",
		url : __URL("ADMIN_MAIN/member/memberMessagelist"),
		data : { 
			"page_index" : page_index, 
			"page_size" :  $("#showNumber").val()
		},
		success : function(data) {
			if (data["data"].length > 0) {
				$(".table-class tbody").empty();
				for (var i = 0; i < data["data"].length; i++) {
					var html = '';
					html += '<tr align="center">';
					html += '<td align="center">'+ data['data'][i]['id'] +'</td>';
					html += '<td class="tal"><a onclick=view_member('+data["data"][i]["uid"]+')>'+ data["data"][i]["nick_name"] +'<br>'+ data["data"][i]["user_name"]+'<br>'+ data["data"][i]["user_tel"] +'</a></td>'

					html += '<td align="left"><div>' + timeStampTurnTime(data['data'][i]['create_time']) + '</div>' + data['data'][i]['message'] + '</td>';
					if(data['data'][i]['message_pic'])
					{
						html += '<td align="left"><a target="_blank" href=' + data['data'][i]['message_pic'] + '><img style="width: 50px" src="' + data['data'][i]['message_pic'] + '" ></a><span class="row-50"></span></td>';
					}
					else {
						html += '<td align="left"></td>';

					}
					if(data['data'][i]['status']){
						html += '<td align="left"><div>' + timeStampTurnTime(data['data'][i]['reply_time']) + '</div>' + data['data'][i]['reply'] + '</td>';
						html += '<td align="left">已回复</td>';
					}
					else
					{
						html += '<td align="left"></td>';
						html += '<td align="left">未回复</td>';
					}

					html += '<td><a onclick="modify_user('+ data["data"][i]["id"]+')">修改</a>&nbsp;&nbsp;&nbsp;<a href="javascript:deleteMember('+data['data'][i]['id']+');">删除</a></td>';

					html += '</tr>';
					$(".table-class tbody").append(html);
				}
			} else {
				var html = '<tr align="center"><td colspan="7">暂无符合条件的数据记录</td></tr>';
				$(".table-class tbody").html(html);
			}
			initPageData(data["page_count"],data['data'].length,data['total_count']);
			$("#pageNumber").html(pagenumShow(jumpNumber,$("#page_count").val(),{$pageshow}));
		}
	});
}

function deleteMember(level_id){
	var id = $("#modify_id").val();
	$.ajax({
		type : "post",
		url : "{:__URL('ADMIN_MAIN/member/deleteMemberMessage')}",
		data : { 'level_id' : level_id },
		success : function(data) {
			if (data['code'] > 0) {
				showTip(data['message'],'success');
				LoadingInfo(getCurrentIndex(id,'#productTbody'));
			} else {
				showTip(data['message'],'error');
			}
		}
	});
}

	//修改会员
	function modifyUser(){
		var id = $("#modify_id").val();
		var reply = $("#reply").val();


		var user_data = {
			'id':id,
			'reply' : reply
		};

		$.ajax({
			type : "post",
			url : "{:__URL('ADMIN_MAIN/member/updateMemberMessage')}",
			data : user_data,
			success : function(data) {
				if (data['code'] > 0) {
					showTip(data['message'],'success');
					LoadingInfo(getCurrentIndex(id,'#productTbody'));
					$("#modify_user").modal("hide");
				} else {
					showTip(data['message'],'error');
					flag = false;
				}
			}
		});
	}

</script>
{/block}